package cn.itcast.hotel.config;


import cn.itcast.hotel.constants.MqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class MyConfig {

    @Bean
    TopicExchange topicExchange(){
        return new TopicExchange(MqConstants.HOTEL_EXCHANGE);
    }
    @Bean
    public Queue queueInsert(){
        return new Queue(MqConstants.HOTEL_INSERT_QUEUE);
    }
    @Bean
    public Queue queueDelete(){
        return new Queue(MqConstants.HOTEL_INSERT_QUEUE);
    }
    @Bean
    Binding insertBlinding(){
        return BindingBuilder.bind(queueInsert()) //队列
        .to(topicExchange()) //交换机
        .with(MqConstants.HOTEL_INSERT_KEY); //route_key
    }
    @Bean
    Binding deleteBlinding(){
        return BindingBuilder.bind(queueDelete()) //队列
                .to(topicExchange()) //交换机
                .with(MqConstants.HOTEL_DELETE_KEY); //route_key
    }

}



